package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseDomain;
import cn.itsource.basic.domain.BaseTreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@AllArgsConstructor //全参构造
@NoArgsConstructor  //无参构造
@Data   //get set toString equals  toString  hashCode
@Table(name = "t_department")
@ApiModel(value="部门对象",description = "部门对象吧，懂的都懂")
public class Department extends BaseTreeNode<Department> {

    //编号
    @ApiModelProperty(value = "部门编号")
    @Size(min = 3,max = 6,message = "请输入3-6位的部门编号")
    private String sn;

    //名字
    @NotBlank(message = "部门名称不能为空")
    @ApiModelProperty(value = "部门名称")
    private String name;
    //状态  1：正常 0：禁用
    @ApiModelProperty(value = "部门状态  1：正常 0：禁用")
    private Integer state;
    //部门经理id 对应员工表的id字段
    @ApiModelProperty(value = "部门经理id")
    @Column(name = "manager_id")
    private Long managerId;
    //父部们id
    @ApiModelProperty(value = "上级部门的id")
    @Column(name = "parent_id")
    private Long parentId;
    //先不管
    @ApiModelProperty(value = "先不管他，我也不知道")
    @Column(name = "dir_path")
    private String dirPath;

    //临时字段，不参与数据库curd
    //上级部门名称
    @Transient
    private String parentName;

    /**
     * 上级部门id们
     */
    @Transient
    private Long[] parentIds;

    //部门经理名称
    @Transient
    private String managerName;
}
